package com.example.jacky.android_easeui.demo;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.jacky.android_easeui.R;
import com.example.jacky.android_easeui.base.BaseActivity;
import com.example.jacky.android_easeui.bean.Cheeses;
import com.example.jacky.uilibrary.view.RefreshListView;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by jacky on 2016/10/12.
 * sounbus app-developer
 */

public class RefreshListViewActivity extends BaseActivity {
    public static final String TAG = "RefreshListViewActivity";
    @Bind(R.id.lv)
    RefreshListView mLv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_refresh_listview);
        ButterKnife.bind(this);
        mLv.setAdapter(new MyAdapter());
    }

    class MyAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return Cheeses.NAMES.length;
        }

        @Override
        public String getItem(int arg0) {
            return Cheeses.NAMES[arg0];
        }

        @Override
        public long getItemId(int arg0) {
            return arg0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder;
            if (convertView == null) {
                convertView = View.inflate(RefreshListViewActivity.this, R.layout.item_home, null);
                holder = new ViewHolder();
                holder.tvTitle = (TextView) convertView
                        .findViewById(R.id.demo_tv);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            String item = getItem(position);
            holder.tvTitle.setText(item);
            return convertView;
        }
    }

    static class ViewHolder {
        public TextView tvTitle;
    }
}

